from pages.base_page import BasePage
from selenium.webdriver.common.by import By


class NewCluePage(BasePage):
    url = "/crm/index.php?m=leads&a=add"

    company_name_locator = (By.ID, "name")
    contacts_name_locator = (By.ID,"contacts_name")
    save_btn_locator = (By.CSS_SELECTOR,"#form1 > table > tfoot > tr > td > input:nth-child(1)")
    add_cluepool_locator = (By.ID,'remove')
    clue_whatis_locator = (By.LINK_TEXT, '什么是线索池？')

    phone_number_locator = (By.ID, 'mobile')
    ok_locator = (By.CSS_SELECTOR,'body > div:nth-child(15) > div.ui-dialog-buttonpane.ui-widget-content.ui-helper-clearfix > div > button')

    #点击什么是线索
    def click_whatis_clue(self):
        self.driver.find_element(*self.clue_whatis_locator).click()
    #新建线索中的输入公司名称
    def add_new_company(self,company_name):
        self.driver.find_element(*self.company_name_locator).send_keys(company_name)
    #新建线索中的输入联系人
    def add_new_contacts(self,contacts_name):
        self.driver.find_element(*self.contacts_name_locator).send_keys(contacts_name)
    #点击新建线索中的保存按钮
    def click_save_btn(self):
        self.driver.find_element(*self.save_btn_locator).click()

    #点击进入线索池
    def click_cluepool_btn(self):
        self.driver.find_element(*self.add_cluepool_locator).click()
    #输入新建线索中的手机号
    def add_new_phone(self,phone_number):
        self.driver.find_element(*self.phone_number_locator).send_keys(phone_number)

